<?php

if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';

//    $targetPath = $_SERVER['DOCUMENT_ROOT'] . str_replace('csme.fr', 'csme', $_REQUEST['folder']) . '/';
    $targetFile = str_replace('//', '/', $targetPath) . $_FILES['Filedata']['name'];

    if (move_uploaded_file($tempFile, $targetFile)) {
        echo $targetPath;
    }
}